// Copyright  2004-2008 Backplane Ltd.
//
// This file is part of Ubiquity formsPlayer
//
// Ubiquity formsPlayer is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
//
// Ubiquity formsPlayer is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License
// along with Ubiquity formsPlayer If not, see <http://www.gnu.org/licenses/>.
//	
//
//   Purpose: declaration of CDelayedDelete.
//   $Id$


#pragma once
class CDelayedDelete
{
public:
	//Deletes this, if not in postponement state, otherwise marks this for deletion
	void RequestDeleteAtEarliestConvenience();
protected:
	CDelayedDelete();
	virtual ~CDelayedDelete();
	//Places object in deletion postponement state,  calls to RequestDeleteAtEarliestConvenience
	//	will not immediately delete
	void EnterDeletionPostponementState();
	//Moves out of deletion postponement, later calls to RequestDeleteAtEarliestConvenience will delete this immediately
    //If, during the period of deletion postponement, RequestDeleteAtEarliestConvenience has been called
	//	this will now  be deleted.
	void ExitDeletionPostponementState();
	//Reports whether a postponed deletion has been requested for this object.
	//	This allows processes to abort.
	bool IsAwaitingDeletion();
	//Reports whether the deletion postponement state has been entered.  
	bool IsInDeletionPostponementState();
	//Override to add functionality that will be called immediately when a deletion request has been made
	//	regardless of postponement state.
	virtual bool OnDeleteRequest() = 0;

private:
	//Deletes this, if a request for deletion has been made.
	void HonourDeletionRequests();
	//indicates whether immediate deletion is allowed.
	bool m_bDeleteOK;	
	//indicates whether postponed deletion has been requested.
	bool m_bPleaseDelete;
};